var now = new Date(); // 当前日期
var nowDayOfWeek = now.getDay(); // 今天本周的第几天
var nowDay = now.getDate(); // 当前日
var nowMonth = now.getMonth(); // 当前月
var nowYear = now.getYear(); // 当前年
nowYear += (nowYear < 2000) ? 1900 : 0; //

//获得当前日
function getNowDate(){
	return (formatDate(now));
}
//获得当前日的开始
function getNowDateStart() {
	return (addTimeStartTag(formatDate(now)));
}
//获得当前日的结束
function getNowDateEnd() {
	return (addTimeEndTag(formatDate(now)));
}
// 获得当前周的开始
function getWeekStart() {
	var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
	return (addTimeStartTag(formatDate(weekStartDate)));
}
// 获得当前周的结束
function getWeekEnd() {
	var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
	return (addTimeEndTag(formatDate(weekEndDate)));
}
// 获得当前月的开始
function getMonthStart() {
	var monthStartDate = new Date(nowYear, nowMonth, 1);
	return (addTimeStartTag(formatDate(monthStartDate)));
}
// 获得当前月的结束
function getMonthEnd() {
	var monthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth));
	return (addTimeEndTag(formatDate(monthEndDate)));
}

function getMonthDays(myMonth) {
	var monthStartDate = new Date(nowYear, myMonth, 1);
	var monthEndDate = new Date(nowYear, myMonth + 1, 1);
	var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24);
	return days;
}
function formatDate(date) {
	var myyear = date.getFullYear();
	var mymonth = date.getMonth() + 1;
	var myweekday = date.getDate();

	if (mymonth < 10) {
		mymonth = "0" + mymonth;
	}
	if (myweekday < 10) {
		myweekday = "0" + myweekday;
	}
	return (myyear + "-" + mymonth + "-" + myweekday);
}
function addTimeStartTag(date){
	return date += " 00:00:00";
}
function addTimeEndTag(date){
	return date += " 23:59:59";
}
